<?php
	require '../../include/library.inc.php';
	require '../../include/admin_login.inc.php';
	require '../../include/paging.inc.php';
	
	$sql = "SELECT
				c.photographers_id,
				c.image,
				c.order_number,
				c.published,
				d.title
				
			FROM
				photographers AS c,
				photographers_description AS d
			WHERE
			
				c.photographers_id = d.photographers_id
				
				AND
				
				d.lang_id = '1'
			  ";
			  
	
	
	if (!isset($_GET['sort'])) $_GET['sort'] = 1;
	if (!isset($_GET['sortBy'])) $_GET['sortBy'] = 3;

	$paging = new Paging($sql, $_GET['sortBy'], $_GET['sort'], array(3=>"Подредба"), 30);
	$result = $paging->query();
		
		head_admin("Фотографи");
	?>
	<?php if ($_SESSION['message']) { ?>
	
	<div class="message green">
		<?=$_SESSION['message']?>
	</div>
	<?php unset($_SESSION['message']); } ?>
	<div class="topbuttons"> <a href="photographers_new.php">Добави нов фотограф</a>
    </div>
	<h3>Фотографи (
	  <?=$paging->count()?>
	  )</h3>
	<table id="listing" width="100%" cellpadding="0" cellspacing="0">
		<thead>
			<tr>
                <td>Портрет</td>
                <td>Име</td>
                <td>Публикуван</td>
                <td>Подредба</td>
                <td>Действия</td>
			</tr>
		</thead>
		<tbody>
		<?php
				  
				  
			  $i=1;
			  while ($row = mysql_fetch_object($result)) {				  
				?>
		<tr class="<?=(($i%2)?"none":"zebra")?>">
			<td>
            	<a href="photographers_edit.php?photographers_id=<?=$row->photographers_id?>"  rel="logos"><img class="thumb" src="../photographers/<?=$row->image?>" height="100"/></a></td>
			<td>
            	<a href="photographers_edit.php?photographers_id=<?=$row->photographers_id?>" title="Редактирай">
			<?=sth($row->title)?></a>
            </td>
		    <td class="switch"><?php if ($row->published) { ?>
				<a href="photographers_publish.php?photographers_id=<?=$row->photographers_id?>&publish=0" class="turn_on" name="turn_on" title="Спри"></a>
			<?php } else { ?>
				<a href="photographers_publish.php?photographers_id=<?=$row->photographers_id?>&publish=1" class="turn_off" name="turn_off" title="Публикувай"></a>
			<?php } ?></td>
			<td class="sort"><?php if ($i != 1) { ?>
				<a name="Up" class="sorting_up" title="Нагоре" href="photographers_direction.php?photographers_id=<?=$row->photographers_id?>&direction=1"></a>
			<?php } ?>
			<?php if ($i != ($paging->count())) { ?>
				<a name="Down" class="sorting_down" title="Надолу" href="photographers_direction.php?photographers_id=<?=$row->photographers_id?>&direction=-1"></a>
			<?php } ?>
			&nbsp;<!--ie6 bug-->
            </td>
		    <td class="icons">
            	<a name="Top" class="sorting_top" title="Top" href="photographers_direction.php?photographers_id=<?=$row->photographers_id?>&top=1">Top</a> <a href="photographers_edit.php?photographers_id=<?=$row->photographers_id?>" class="edit" title="Редактирай">Редактирай</a> 
                <a onClick="if (window.confirm('Сигурен ли си, че искаш да изтриеш <?=sth($row->Name)?>?')) { document.location='photographers_del.php?photographers_id=<?=$row->photographers_id?>'; return false; }" class="delete" title="Изтрий">Изтрий</a></td>
			</tr>
		<?php
				  $i++;    
				} 
			 ?>
		</tbody>
	</table>
	<div class="pagingwrap">
		<div class="paging">
			<?=$paging->display()?>
		</div>
	</div>
<?php
	foot_admin(); 
?>
